#include<iostream>
#include <cstring>
#include <string>
std::string getReversalOFString(char str[], int length)
{
	char *temp;
	std::string result;
	temp = str;
	int m = 0;
	int n = 0;
	char aa[10][10] = {0};
	int number[10] = {0};
	for (int i = 0; i <=length; i++)
	{
		if (*(temp + i) >= 'a'&&*(temp + i) <= 'z'|| *(temp + i) >= 'A'&&*(temp + i) <= 'Z')  //判断是否为英文字母
		{
			aa[m][i - n] = *(temp + i);                       //将英文储存于字符串数组中
		}
		else                                               //遇到空格，则数组行数加一，即每一行存储一个单词
		{
			number[m] = i - n;
			m++;
			n = i+1;
		}
	}
	for (int j = m; j >= 0; j--)                              //将数组行数倒序输出，列数顺序不变
	{
		for (int k = 0;k <number[j]; k++)
		{
			if(aa[j][k]!= '\0')
				result += aa[j][k];


		}
		if (aa[j][0] != '\0')
		{
			result += ' ';
		}
	}

return result;

}

int main(int argc, char** argv)
{	
	std::string result1;
	/*char str0[20] = "I   a  bot";*/
	char str0[20] = { 0 };
	std::cout << "请输入英文语句：";	
	std::cin.getline(str0, 100);

	int length = strlen(str0);
	result1 = getReversalOFString(str0, length);
	std::cout << "反转的英文语句为：" << result1 << std::endl;
	

}